#include "split_string.h"

vector<string> split(const string& str, char delim, bool skip_empty) {
    vector<string> result;
    if (str.size() == 0)
        return result;
    istringstream iss(str);
    for (string item; getline(iss, item, delim); )
        if (skip_empty && item.empty()) continue;
        else result.push_back(item);
    return result;
}


vector<string> split(const string &text, char sep,) {
    vector<string> tokens;
    size_t start = 0, end = 0;
    while ((end = text.find(sep, start)) != string::npos) {
        if (end != start) {
          tokens.push_back(text.substr(start, end - start));
        }
        start = end + 1;
    }
    if (end != start) {
       tokens.push_back(text.substr(start));
    }
    return tokens;
}